package com.sanjiahantang.youjiaclient.module.decorate.models.impl;

import android.content.Context;

import com.sanjiahantang.youjiaclient.base.BaseBean;
import com.sanjiahantang.youjiaclient.base.CallBack;
import com.sanjiahantang.youjiaclient.config.ConfigValue;
import com.sanjiahantang.youjiaclient.http.BaseDelegate;
import com.sanjiahantang.youjiaclient.http.OkHttpClientManager;
import com.sanjiahantang.youjiaclient.module.common.beans.StringBean;
import com.sanjiahantang.youjiaclient.module.decorate.beans.CheckPayBean;
import com.sanjiahantang.youjiaclient.module.decorate.beans.DecorateDicBean;
import com.sanjiahantang.youjiaclient.module.decorate.beans.DecorateManageBean;
import com.sanjiahantang.youjiaclient.module.decorate.models.IDecorateModel;
import com.squareup.okhttp.Request;

import java.util.Map;

/**
 * Created by zy on 2017/9/14.
 */

public class DecorateModel implements IDecorateModel {
    @Override
    public void loadTab(final Context context, Map<String, String> params, final CallBack<DecorateManageBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/engniee/phone/info/customer/searchProjectInfoForCustomer", params,
                new BaseDelegate.ResultCallback<DecorateManageBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(DecorateManageBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }


    @Override
    public void loadIndexDic(final Context context, Map<String, String> param, final CallBack<DecorateDicBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/user/phone/require/indexDecorateInfoIntention", param,
                new BaseDelegate.ResultCallback<DecorateDicBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(DecorateDicBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void saveUserRequireInfoIntention(final Context context, Map<String, Object> param, final CallBack<StringBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/user/phone/require/saveUserRequireInfoIntention", param,
                new BaseDelegate.ResultCallback<StringBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(StringBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void indexDecorateInfoForCustomer(final Context context, Map<String, String> param, final CallBack<DecorateDicBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/user/phone/require/indexDecorateInfoForCustomer", param,
                new BaseDelegate.ResultCallback<DecorateDicBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(DecorateDicBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void saveUserRequireInfoForCustomer(final Context context, Map<String, Object> param, final CallBack<StringBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/user/phone/require/saveUserRequireInfoForCustomer", param,
                new BaseDelegate.ResultCallback<StringBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(StringBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void updateEngnieeInfo(final Context context, Map<String, String> param, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/engniee/phone/info/role/updateEngnieeInfoCustomer", param,
                new BaseDelegate.ResultCallback<BaseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void engnieeNeedMoney(final Context context, Map<String, String> param, final CallBack<CheckPayBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/engniee/phone/info/customer/engnieeNeedMoney", param,
                new BaseDelegate.ResultCallback<CheckPayBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(CheckPayBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void findIsPushStateId(final Context context, Map<String, String> param, final CallBack<StringBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/project/price/phone/customer/findIsPushStateId", param,
                new BaseDelegate.ResultCallback<StringBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(StringBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void engnieeIsOfficeNextStatus(final Context context, Map<String, String> param, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/engniee/phone/info/customer/engnieeIsOfficeNextStatus", param,
                new BaseDelegate.ResultCallback<BaseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }
}
